// 注册登录滑动效果
$(function(){
    function loginanimate(){
        var SignInBtn = document.querySelector('#signin');
    var SignUpBtn = document.querySelector('#signup');
    var container= document.querySelector("#control");
    SignUpBtn.addEventListener("click",function(){
        container.className="container";
    })
    SignInBtn.addEventListener("click",function(){
        container.className="container right-panel-active";
    })
    
    // 鼠标悬停输入框效果
    var input=document.querySelectorAll("input");
    var offsettop=new Array();
    for(var i=0;i<input.length;i++){
        offsettop[i]=input[i].previousElementSibling.offsetTop;
        }
    for(var i=0;i<input.length;i++) {
        input[i].addEventListener('focus',function(){
            for(var j=0;j<input.length;j++){
            if(!input[j].value){
            input[j].previousElementSibling.style.top=offsettop[j]+'px';
            if(input[j].getAttribute("class")!="vrcode"){
                input[j].nextElementSibling.style.width="0";
            }
            else{
                input[j].nextElementSibling.nextElementSibling.style.width="0";
            }
            }
            }
            if(!this.value){
                this.previousElementSibling.style.top=this.previousElementSibling.offsetTop-20+'px';
            if(!(this.getAttribute("class")=="vrcode")){
                this.nextElementSibling.style.width="80%";
            }
            else {
                this.nextElementSibling.nextElementSibling.style.width="60%";
                this.previousElementSibling.style.top=this.previousElementSibling.offsetTop-25+'px';
            }
            }
        })
        input[i].addEventListener('blur',function(){
            if(!this.value){
            if(!(this.getAttribute("class")=="vrcode")){
                this.previousElementSibling.style.top=this.previousElementSibling.offsetTop+20+'px';
                this.nextElementSibling.style.width="0%";
            }
            else {
                this.previousElementSibling.style.top=this.previousElementSibling.offsetTop+25+'px';
                this.nextElementSibling.nextElementSibling.style.width="0%";
            }}
        })
    }
    }
    
    // 密码显示效果
    function passwddisplay(){
        var pwddisplay=document.querySelectorAll(".pwddisplay");
        var pwdinput1=document.querySelector(".pwdinput1");
        var pwdinput2=document.querySelector(".pwdinput2");
        var pwdflag=1;
        for(var i=0;i<pwddisplay.length;i++){
        pwddisplay[i].addEventListener('click',function(){
            if(pwdflag){
                this.src="images/eye-blocked.png";
                pwdflag=0;
                if(this.parentNode.className=="form-signup"){
                    pwdinput2.type="text";
                }
                else if(this.parentNode.className=="form-signin") {
                    pwdinput1.type="text";
                }
            }
            else {
                this.src="images/eye.png";
                pwdflag=1;
                if(this.parentNode.className=="form-signup"){
                    pwdinput2.type="password";
                }
                else if(this.parentNode.className=="form-signin") {
                    pwdinput1.type="password";
                }
            }
        })}
    }
    loginanimate();
    passwddisplay();
})

